﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public abstract class SteerBase : MonoBehaviour {
    public virtual string CName
    {
        get { return SteerName.StN_SteerBase; }
    }
    public float m_fWeight = 1;
    private Vector3 m_v3Force = Vector3.zero;
    public Action<SteerBase> OnArrival = delegate { };
    public abstract Vector3 CalculateForce();
    private bool m_bReportArrival = false;
    public Vector3 Force
    {
        get
        {
            m_v3Force = CalculateForce();
            if(m_v3Force != Vector3.zero)
            {
                m_bReportArrival = true;
            }
            else if(m_bReportArrival)
            {
                if (OnArrival != null)
                {
                    OnArrival(this);
                }
                if (m_v3Force == Vector3.zero)
                {
                    m_bReportArrival = false;
                }
            }
            return m_v3Force;
        }
    }
    public float Weight
    {
        get { return m_fWeight; }
        set { m_fWeight = value; }
    }
    protected Vehicle m_pVehicle;

    public void Init(Vehicle _vehicle)
    {
        m_pVehicle = _vehicle;
    }
}

public class SteerName
{
    //类的名字
    public const string StN_SteerBase = "SteerBase";
    public const string StN_SteerSeparation = "SteerSeparation";
    public const string StN_SteerForPoint = "SteerForPoint";
    public const string StN_SteerFlee = "SteerFlee";
    public const string StN_SteerForward = "SteerForward";
}
